<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="../../common/tagInclude.jsp" %>
<%@include file="../../common/headerInclude.jsp" %>
<script>
	KindEditor.ready(function(K) {
		var editor1 = K.create('textarea[name="content"]', {
			cssPath : '${basePath}kindeditor/plugins/code/prettify.css',
			uploadJson : '${basePath}kindeditor/jsp/upload_json.jsp',
			fileManagerJson : '${basePath}kindeditor/jsp/file_manager_json.jsp',
			allowFileManager : true,
			afterCreate : function() {
				var self = this;
				K.ctrl(document, 13, function() {
					self.sync();
					document.forms['jvForm'].submit();
				});
				K.ctrl(self.edit.doc, 13, function() {
					self.sync();
					document.forms['jvForm'].submit();
				});
			}
		});
		prettyPrint();
	});
	$(function() {
		$("#jvForm").validate();
	});
	function changeContentType(typeId){
		if(typeId == '1'){
			document.getElementById("richContentDiv").style.display = "block" ;
			document.getElementById("textContentDiv").style.display = "none" ;
		}
		else{
			document.getElementById("textContentDiv").style.display = "block" ;
			document.getElementById("richContentDiv").style.display = "none" ;
		}
	}
	function pageLoad(){
		var contentType = "${performance.contentType}";
		changeContentType(contentType);
	}
</script>
<title>公司业绩<c:choose><c:when test="${opt == 'update'}">修改</c:when><c:otherwise>添加</c:otherwise></c:choose></title>
<script src="<%=projectBasePath%>res/jeecms/js/prototype-1.6.0.3.js" type="text/javascript"></script>
<script type="text/javascript" src="${basePath}res/common/js/My97DatePicker/WdatePicker.js"></script>
</head>
<body onload="javascript:pageLoad();">
<div class="body-box">
	<div class="rhead">
		<div class="rpos">当前位置: 首页 - 公司业绩 - 内容<c:choose><c:when test="${opt == 'update'}">修改</c:when><c:otherwise>添加</c:otherwise></c:choose></div>
		<div class="clear"></div>
	</div>
	<form method="post" action="${basePath}super/performance/performance-${opt}.do" id="jvForm" enctype="multipart/form-data">
		<input type="hidden" id="performanceId" name="performanceId" value="${performance.performanceId}"/>
		<table width="100%" class="pn-ftable" cellpadding="2" cellspacing="1" border="0">
			<tbody>
			<tr>
				<td width="15%" class="pn-flabel pn-flabel-h"><span class="pn-frequired">*</span>语种:</td>
				<td width="85%" class="pn-fcontent">
					<select id="languageId" name="languageId" class="required"  onfocus="this.languageId=this.selectedIndex;" onchange="this.selectedIndex=this.languageId;">
						<option value="">请选择语种</option>
						<option value="1" <c:if test="${performance.languageId == 1}">selected</c:if>>中文</option>
						<option value="2" <c:if test="${performance.languageId == 2}">selected</c:if>>英文</option>
					</select>
				</td>
			</tr>
			<tr>
				<td width="15%" class="pn-flabel pn-flabel-h"><span class="pn-frequired">*</span>栏目:</td>
				<td width="85%" class="pn-fcontent">
					<select id="cateId" name="cateId" class="required">
						<option value="">请选择栏目</option>
						<c:forEach items="${cateList}" var="cate">
							<option value="${cate.cateId}"  <c:if test="${performance.cateId == cate.cateId}">selected</c:if>>${cate.name}</option>
						</c:forEach>
					</select>
				</td>
			</tr>
			<tr>
				<td width="15%" class="pn-flabel pn-flabel-h"><span class="pn-frequired">*</span>标题:</td>
				<td width="85%" class="pn-fcontent">
					<input type="text" maxlength="100" name="title" id="title" class="required" size="80" value="${performance.title}">
				</td>
			</tr>
			<tr>
				<td width="15%" class="pn-flabel pn-flabel-h"><span class="pn-frequired">*</span>来源:</td>
				<td width="85%" class="pn-fcontent">
					<input type="text" maxlength="100" name="publishFrom" id="publishFrom" class="required" size="80" value="${performance.publishFrom}">
				</td>
			</tr>
			<tr>
				<td width="15%" class="pn-flabel pn-flabel-h"><span class="pn-frequired">*</span>发布人:</td>
				<td width="85%" class="pn-fcontent">
					<c:choose>
						<c:when test="${empty performance.author}">
							<c:if test="${languageId == 1}">
								<c:set var="Author"  value="管理员" />
							</c:if>
							<c:if test="${languageId == 2}">
								<c:set var="Author" value="admin" />
							</c:if>
						</c:when>
						<c:otherwise>
							<c:set var="Author" value="${performance.author}" />
						</c:otherwise>
					</c:choose>
					<input type="text" maxlength="100" name="author" id="author" class="required" size="80" value="${Author}">
				</td>
			</tr>
			<tr>
				<td width="15%" class="pn-flabel pn-flabel-h"><span class="pn-frequired">*</span>发布时间:</td>
				<td width="85%" class="pn-fcontent">
					<input type="text" maxlength="100" name="publishDate" id="publishDate" class="required" size="35" value="${performance.publishDate}"
					onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="Wdate" readonly="readonly">
				</td>
			</tr>
			<tr>
				<td width="15%" class="pn-flabel pn-flabel-h"><span class="pn-frequired"></span>关键字:</td>
				<td width="85%" class="pn-fcontent">
					<input type="text" maxlength="100" name="metaKeyword" id="metaKeyword" size="80" value="${performance.metaKeyword}">
				</td>
			</tr>
			<tr>
				<td width="15%" class="pn-flabel pn-flabel-h"><span class="pn-frequired"></span>摘要描述:</td>
				<td width="85%" class="pn-fcontent">
					<textarea rows="5" cols="50" name="metaContent" id="metaContent" >${performance.metaContent}</textarea>
				</td>
			</tr>
			<tr>
				<td width="15%" class="pn-flabel pn-flabel-h"><span class="pn-frequired"></span>图片上传:</td>
				<td width="85%" class="pn-fcontent" id="imageOpr">
					<c:choose>
					<c:when test="${opt == 'update'}">
						<c:choose>
							<c:when test="${!empty performance.firstImage}">
								<img src="${basePath}${performance.firstImage}" width="104" height="100" />&nbsp;<a href="javascript:delImage(${performance.performanceId});">删除</a>
							</c:when>
							<c:otherwise>
								<input type="file" maxlength="100" name="image" id="image" size="80" value="">
							</c:otherwise>
						</c:choose>
					</c:when>
					<c:otherwise>
						<input type="file" maxlength="100" name="image" id="image" size="80" value="">
					</c:otherwise>
					</c:choose>
				</td>
			</tr>
			<tr>
				<td width="15%" class="pn-flabel pn-flabel-h"><span class="pn-frequired">*</span>内容:</td>
				<td width="85%" class="pn-fcontent">
					编辑模式:<input type="radio" id="contentType" name="contentType" value="0" <c:if test="${performance.contentType == 0}">checked</c:if> onclick="javascript:changeContentType('0');"/>纯文本编辑&nbsp;
							<input type="radio" id="contentType" name="contentType" value="1" <c:if test="${performance.contentType == 1}">checked</c:if> onclick="javascript:changeContentType('1');"/>富文本编辑&nbsp;
					<span class="pn-frequired">内容不能为空!</span>
				</td>
			</tr>
			<tr>
				<td width="100%" class="pn-fcontent" colspan="2" align="center">
					<div id="richContentDiv" style="display:none">
						<textarea name="content" id="content" cols="100" rows="8" style="width:95%;height:300px;">${performance.content}</textarea>
					</div>
					<div id="textContentDiv" style="display:none">
					<textarea name="textContent" id="textContent" cols="100" rows="8" style="width:95%;height:300px;">${performance.content}</textarea>
					</div>
				</td>
			</tr>
			<tr>
				<td colspan="2" class="pn-fbutton">
					<input type="submit" value="提交"> &nbsp; <input type="reset" value="重置">
				</td>
			</tr>
			</tbody>
		</table>
	</form>
</div>
<script type="text/javascript">
	function delImage(performanceId){
		if(!confirm('确认要删除指定图片?'))return;
		var url = '${basePath}super/performance/performance-delImage.do';
        var pars = 'performanceId=' + performanceId ;
        var myAjax = new Ajax.Request(
                    url,
                    {method: 'get', parameters: pars, onComplete: showResponse}
        );
    }
    function showResponse(originalRequest){
        $('imageOpr').innerHTML =  '<input type="file" maxlength="100" name="image" id="image" size="80" value="">' ;
    }
</script>
</body>
</html>